<!DOCTYPE html>
<html lang="ar">
<head>
    <title>قائمة الالتزامات</title>
	<?php
	 define('LAST_CAPITRE_ID',19);
	 define('LAST_ARTICLE_CODE',3);
	?>
	
	<?php $this->load->helper('url');?>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta charset="utf-8">
		<!---------------------for autocomplete--------------->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-1.11.0.min.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/jquery-ui.css")?>" rel="stylesheet" type="text/css" />
	<!------------------------------------------------------>


<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.tablesorter.min.js');?>" ></script>
		<link href="<?php echo base_url("assets/css/table.css")?>" rel="stylesheet" type="text/css" />
	<link href="<?php echo base_url("assets/css/ch_menu.css")?>" rel="stylesheet" type="text/css" />
	 <link href="<?php echo base_url("assets/css/botton.css")?>" rel="stylesheet" type="text/css" />
	
</head>


<?php include_once('header.php');
	
	
		 $this->load->library('session');
        $num_ar=$this->session->userdata('data_charticle'); //access it
        $chcl=$num_ar;
        $chemin=$this->uri->uri_string;
$liste_des_fournisseurs= array();
foreach ($results_recherche as $lf){
	array_push($liste_des_fournisseurs, $lf->nom);
	}
	
	?>
	
	<div class="container">

	<form id="recherche_frm" method="post" action="<?php echo base_url("engagement_crt/find_name/");?>" >
	 <fieldset>
	   <div class="pure-g">
	  <div class="pure-u-1 pure-u-md-1-3">
                <input id="nom" name="nom" type="text" value="<?php 
				if($results_recherche){
				echo($results_recherche[0]->nom);	
				}
				
				?>">
				<label for="nom">المورد </label>
            </div>
		 <button type="submit" id="submit_btn" class="pure-button pure-button-primary" style="margin-top: 1%;">بحث</button>
		   </div>
		  </fieldset>
	</form>

	


<div class = "charticle_browser">
	
<ul class="topmenu" id="css3menu1">
<?php

$mem =0;


for($i = 0; $i < count($chcl); $i++)
{
	if($mem <> $chcl[$i]->id_chapitre)
			{	
				echo('<li class="topmenu"><a style="width:248px;" href="#"><span>
				<img alt="" src="images/sparkle-brown-vertical/info2.png">'. $chcl[$i]->ch_code.'- '.$chcl[$i]->nom_chap.' </span></a>');
				echo('<div style="auto;" class="submenu">');
				echo('<div style="width:100%" class="column">');

			
				echo('<ul><li><a href="'.base_url("engagement_crt/get_engagement_per_article2/").'/'.$chcl[$i]->id_article.'">
				<img alt="" src="images/sparkle-brown-vertical/bookmarks.png">'.$chcl[$i]->code.'- '.$chcl[$i]->nom_art.'</a></li><br>');

				if(($chcl[$i]->code)== 1 && ($chcl[$i]->id_chapitre == 16))  echo('</ul></div></div></li>'); // patch to fix a unique child
				
			}
			else
			{

				
				echo('<li><a href="'.base_url("engagement_crt/get_engagement_per_article2/").'/'.$chcl[$i]->id_article.'">
				<img alt="" src="images/sparkle-brown-vertical/bookmarks.png">'.$chcl[$i]->code.'- '.$chcl[$i]->nom_art.'</a></li><br>');

				if($chcl[$i+1]->id_chapitre > $mem) echo('</ul></div></div></li>');
				if(($chcl[$i]->code)== 2 && ($chcl[$i]->id_chapitre == 19))  //if last chapitre et article
				 {

				 
				 	echo('<li><a href="'.base_url("engagement_crt/get_engagement_per_article2/").'/'.$chcl[$i]->id_article.'">
					<img alt="" src="images/sparkle-brown-vertical/bookmarks.png">'.$chcl[$i]->code.'- '.$chcl[$i+1]->nom_art.'</a></li><br>');

				 	 echo('</ul></div></div></li>');
					//goto end;
					break;
				 }
			}
			    $mem = $chcl[$i]->id_chapitre;	
}	
 ?>
 </ul>
 </div>
</div>

<div id="destination" >
  <h1 style="margin-left:20%; "><?php echo $titre;   ?></h1>
  <div id="body">
  
  
   <div class="CSS_Table_Example"> 
   <table id="myTable" class="tablesorter">
  <thead>
<tr>

  <th>    المبلغ العملية </th>
  
  <th>  مبلغ القديم   </th>
  <th>    الطبيعة </th>
  
  <th>  التاريخ   </th>
   <th>  المادة   </th>
   <th>    الرقم  </th>
</tr>
</thead>
<?php

foreach($results as $data) 
{
	$id=$data->id_engagement;
	echo '<tr >	  
	        <td>'.$data->montant_engagement.'</td>
		    <td>'.$data->montant_precedent.'</td>
		   <td>'.$data->nature.'</td>
		    <td>'.$data->date.'</td>
		   <td>'.$data->nom.'</td>		
		  <td> <a href='.base_url("/engagement_crt/detaille_engagement/$data->id_engagement").'>'.$data->numero.'</a></td>
		  </tr>'  ;
	
}

$erreur=0;  
?>
</table>
</div>
<div class="pagination_numero" >
  <p><?php echo $links;   ?></p>
 </div>
  </div>
  <div>  
<form  style="position: relative; left: 10%;">
<a href="<?php echo base_url("/budget_ctr/load/")?>" class="botton">خروج</a>

</form> 


</div>
</div>
  <script>
 $(document).ready(function() 
    { 
        $("#myTable").tablesorter(); 
    } 
); 
 </script>   

<script>
$(function() {
	var liste_fourniss = <?php echo json_encode($liste_des_fournisseurs); ?>;
	$( "#nom" ).autocomplete({source: liste_fourniss});
	} 
); 
</script>
</html>